﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using SimpleFS.Core;

namespace SimpleFS.Services.Transactions.Implementations.Files
{
    public class Copy : TransactableOperationTemplate
    {
        internal IFile source = null;

        internal IFile target = null;

        public Copy(IFile source, IFile target, IResourceManager resourceManager)
        {
            this.source = source;
            this.target = target;
            base.resourceManager = resourceManager;
        }

        protected override void Operate()
        {
            Stream stream = this.source.Read();
            //Write write = new Write(this.target, stream, base.resourceManager);
            //write.Execute();
            // the target should be a transactble object.
            this.target.Write(stream);

            stream.Close();
        }

        public override void Commit()
        {
            
        }

        public override void Rollback()
        {
            
        }
    }
}
